package com.eurekaClient.service;

import com.eurekaClient.pojo.User;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

@Service
public class RedisService {

    private static org.slf4j.Logger Logger = LoggerFactory.getLogger(RedisService.class);

    @Autowired
    private RedisTemplate redisTemplate;

    public boolean setUser(User user){
        ValueOperations ops = redisTemplate.opsForValue();
        ops.set(user.getNickname(), user);
        Logger.info("{}",user.toString());
        return true;
    }

    public User getUser(String name){
        ValueOperations ops = redisTemplate.opsForValue();
        return (User) ops.get(name);
    }



}